package com.hyfd.service.mp;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.hyfd.common.BaseJson;
import com.hyfd.common.Page;
import com.hyfd.common.utils.MapUtils;
import com.hyfd.dao.mp.AgentDao;
import com.hyfd.dao.mp.SubmitOrderDao;
import com.hyfd.service.BaseService;

@Service
public class SubmitOrderSer extends BaseService{

	Logger log = Logger.getLogger(SubmitOrderSer.class);
	@Autowired
	AgentDao agentDao;
	@Autowired
	SubmitOrderDao submitOrderDao;
	
	/**
	 * 根据条件查询数据列表
	 * @author lks 2017年5月4日上午8:53:16
	 * @param request
	 * @return
	 */
	public String submitOrderList(HttpServletRequest request){
		Map<String,Object> param = getMaps(request);
		StringBuilder sb=new StringBuilder();
		try{
			Page p=getPage(param);//提取分页参数
			int total=submitOrderDao.selectCount(param);
			p.setCount(total);
			int pageNum=p.getCurrentPage();
			int pageSize=p.getPageSize();
			sb.append("{");
			sb.append(""+getKey("page")+":"+p.getCurrentPage()+",");
			sb.append(""+getKey("total")+":"+p.getNumCount()+",");
			sb.append(""+getKey("records")+":"+p.getCount()+",");
			sb.append(""+getKey("rows")+":"+"");
			PageHelper.startPage(pageNum, pageSize);//mybatis分页插件
			List<Map<String,Object>> dataList = submitOrderDao.selectAll(param);
			String dataListJson=BaseJson.listToJson(dataList);
			sb.append(dataListJson);
			sb.append("}");
		}catch(Exception e){
			log.error("订单提交记录列表查询方法出错"+e.getMessage());
		}
		return sb.toString();
	}
	
}
